package com.qifenqian.turbot.module.ui.setting

import android.content.Context
import android.content.Intent
import android.view.View
import com.qifenqian.turbot.R
import com.qifenqian.turbot.base.BaseActivity
import com.qifenqian.turbot.module.contract.AccountContract
import com.qifenqian.turbot.module.presenter.AccountPresenter
import kotlinx.android.synthetic.main.activity_help.*
import org.jetbrains.anko.toast

class HelpActivity : BaseActivity<AccountPresenter, AccountContract.View>(), AccountContract.View {
    companion object {
        fun startThis(context: Context) {
            val intent = Intent(context, HelpActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun bindLayoutId(): Int {
        return R.layout.activity_help
    }

    override fun bindPresenter(): AccountPresenter? {
        return AccountPresenter(this, this)
    }

    private var mPhone: String = "0755-5888555"
    private var tips = "请描述您所遇到的问题或提出您的建议，我们将尽快与您联系。\n或者您直接拨打客服热线：$mPhone（上班时间：8:30-17:30）"
    override fun initial() {
        tv_help_tips.setSpannableText(tips, mPhone, View.OnClickListener { toast(mPhone) })
        btn_help_next.setOnClickListener {
            if (et_help_content.text.toString().isBlank()) {
                toast("请输入反馈内容")
                return@setOnClickListener
            }
            mPresenter!!.giveFeedback(et_help_content.text.toString())
        }
    }

    override fun giveFeedbackResult(isSuccess: Boolean, code: Int, msg: String?) {
        if (isSuccess) {
            finish()
        }
        toast(msg!!)
    }


}
